import { Component, OnInit } from '@angular/core';
import {NzModalService} from "ng-zorro-antd";

declare var form: any;
declare var security: any;

@Component({
  templateUrl: './passenger.check.component.html'
})
export class PassengerCheckComponent implements OnInit {

  ss: any;
  // 表单
  fs: any = null;
  ffs: any;
  // 字典
  airportDic: any = null;
  constructor(private modal: NzModalService) {
    this.ss = security.SecurityService;
    this.ffs = new form.FileService();
    this.fs = new form.FormSimpleService('cyclepassengercheck', {
      orderObject: { id: 0 },
      keyField: 'id',
      randomFields: ['id'],
      // 加入导入配置中的配置编号
      inputid: 'lkaqjc',
      // Excel中导入数据的开始行(第一行为0)
      startrow: 3
    });
    this.fs.loadData(true);

    this.airportDic = new form.DictionaryService('zd_airport');
  }

  ngOnInit() {
  }
  editRow(item) {
    if (item) {
      window.open('#data_cycle_passengerinfo_mis?info=true&id=' + item.id);
    } else {
      window.open('#data_cycle_passengerinfo_mis?info=true');
    }
  }
  // 文件上传后处理
  excelHandleChange(obj) {
    this.fs.excelHandleChange(obj, () => {
      this.fs.loadData(true);
      this.modal.success({
        nzTitle: '系统提示',
        nzContent: '数据导入成功'
      });
    }, () => {
      this.modal.error({
        nzTitle: '系统提示',
        nzContent: '数据导入失败，详细请查看数据导入日志！'
      });
    });
  }
}
